# 查询队伍ID
def select_gun(ziduan_name, table_name):
    sql = "SELECT {} FROM {}".format(ziduan_name, table_name)

    return sql


# 插入队伍
def insert_duiwu(table_name):
    if table_name == 'bisai_get_bb' or table_name == 'bisai_get_od':
        sql = f"insert into {table_name}(bisai_time, match_name, Team_name_1, Team_name_2, region_name,info_score, yellow_card, red_card, corner, current_game_time,game_id, region_id, competition_id) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    elif table_name == 'bisai_get_fb':
        sql = "insert into bisai_get_fb(bisai_time, match_name, Team_name_1, Team_name_2, region_name,info_score, yellow_card, red_card, corner, current_game_time, game_id) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    elif table_name == "bisai_fb_bb_duiwu" or table_name == "bisai_fb_od_duiwu" or table_name == "bisai_od_bb_duiwu":
        sql = f"insert into {table_name} (bisai_time, FB_match_name, FB_Team_name_1, FB_Team_name_2, BB_match_name, BB_Team_name_1, BB_Team_name_2, FB_diqu, BB_diqu,FB_game_id,BB_game_id,BB_region_id, BB_competition_id,FB_corner,BB_corner,is_corner) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    elif table_name == "valid_data":
        sql = "insert into valid_data(Capture_time, FB_match_name, BB_match_name, Game_time, Score, FB_Team_name, BB_Team_name, category, FB_playing, FB_multiple, BB_playing, BB_multiple, Valid_data, time_time,corner) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    elif table_name == "profit_loss":
        sql = "insert into profit_loss(Capture_time, FB_match_name, BB_match_name, Game_time, Score, FB_Team_name, BB_Team_name, category, FB_playing, FB_multiple, BB_playing, BB_multiple, Valid_data, profit_loss, time_time) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    elif table_name == 'bisai_get_ss':
        sql = "insert into bisai_get_ss(bisai_time, match_name, Team_name_1, Team_name_2, info_score, current_game_time,game_id) values(%s,%s,%s,%s,%s,%s,%s)"

    elif table_name == "bisai_fb_ss_duiwu":
        sql = "insert into bisai_fb_ss_duiwu(bisai_time, FB_match_name, FB_Team_name_1, FB_Team_name_2, BB_match_name, BB_Team_name_1, BB_Team_name_2, FB_diqu, BB_diqu,FB_game_id,BB_game_id, FB_corner,BB_corner,is_corner) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

    elif table_name == "bb_results" or table_name == "fb_results":
        sql = "insert into {}(bisai_time, region_name, match_name, Team_name_1, Team_name_2, scores_ban, scores, game_id) values(%s,%s,%s,%s,%s,%s,%s,%s)".format(
            table_name)

    else:
        sql = -1

    return sql


# 更新
def update_duiwu(table_name, ziduan_name_1, ziduan_name_2):
    sql = "UPDATE {} SET {} =%s WHERE {}=%s".format(table_name, ziduan_name_1, ziduan_name_2)
    return sql


# 删除
def dllete_duiwu(table_name, ziduan_name):
    sql = "DELETE FROM {} WHERE {} = %s".format(table_name, ziduan_name)

    return sql


# 插入数据
def insert_data(table_name):
    sql = "insert into {}(Capture_time, match_name, Game_time, score, Team_name_1, Team_name_2, ty_pe, type_name_1, playing_1, multiple_1, type_name_2, playing_2, multiple_2, time_time, game_id) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)".format(
        table_name)
    return sql

def insert_data_1(table_name):
    sql = "insert into {}(Capture_time, match_name, Game_time, score, Team_name_1, Team_name_2, ty_pe, type_name_1, playing_1, multiple_1, type_name_2, playing_2, multiple_2, time_time, game_id,corner) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)".format(
        table_name)
    return sql

def select_pp(table_name, t1):
    sql = "SELECT * FROM {} WHERE time_time > {}".format(table_name, t1)
    return sql


def dllete_pp(table_name):
    sql = "DELETE FROM {} WHERE time_time < %s".format(table_name)

    return sql